
/*---------------*/
/* Joseph Porter */
/* Summer of 2012*/
/* Team 1247     */
/*www.ROKSBOT.com*/
/* LimitSwitch   */
/*---------------*/
package Team1247Classes.Sensors;

import edu.wpi.first.wpilibj.DigitalInput;


public class LimitSwitch {
    private int digitalChannel;
    private DigitalInput digitalInput;
    private boolean normallyOpen;
    private boolean normallyClosed;
    private boolean state;
    public LimitSwitch(int digitalChannel, boolean normallyOpen){
        this.digitalChannel = digitalChannel;
        if(!normallyOpen){
            this.normallyClosed = true;
            this.normallyOpen = false;
        }
        else{
            this.normallyClosed = false;
            this.normallyOpen = true;
        }
        
        this.digitalInput = new DigitalInput(this.digitalChannel);
    }
    public boolean checkState(){
        if(this.normallyClosed){
            this.state = !this.digitalInput.get();
        }
        if(this.normallyOpen){
            this.state = this.digitalInput.get();
        }
        return this.state;
    }
}
